<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/2/25 0025
 * Time: 下午 5:43
 */
include  __DIR__."/functions.php";

//1.根据城市拼音获取线路分类信息
/*$url = "http://api.8684.cn/bus_api_v1.php";
$data = "appkey=Yv9cL8wTwZgr&k=all_lines&ecity=shanghai";
echo curlRequest($url,$data,"POST");*/
//2.查看一条具体路线的去程与返程信息
/*$url = "http://api.8684.cn/bus_api_v1.php";
$data = "k=the_line&appkey=Yv9cL8wTwZgr&ecity=shanghai&q=ff5f95a6";
echo curlRequest($url,$data,"POST");*/
//3.根据站点查看经过的线路信息
/*$url = "http://api.8684.cn/bus_api_v1.php";
$data = "k=the_zhan&appkey=Yv9cL8wTwZgr&ecity=shanghai&q=34086185";
echo curlRequest($url,$data,"POST");*/
//4.按拼音首字母进行分类的城市信息网站：http://js.8684.cn/citys/city_boxInf.min.js
//$url = "http://js.8684.cn/citys/city_boxInf.min.js";
 #echo curlRequest($url);
//根据用户ip地址获取用户所在的城市，参考实例在http://lbsyun.baidu.com/index.php?title=webapi
//说明：每个key支持10万次/天，超过限制不返回数据
function to36encode($char)
{
    if($char === '0' || (ord($char)>=ord('0') && ord($char)<=ord('9') ) )
    {
        $targetStr = strval(ord($char)-ord('0'));
    }elseif(ord($char) >=ord('a') && ord($char) <= ord('z'))
    {
        $targetStr = strval(ord($char) -ord('a')+ord('9')+1);
    }else{
        echo "error:$char = ".$char;
        $targetStr = false;
    }
    return $targetStr;
}
$uuid = 'hjshka11111jkjjlkjslajksjlj';
$lengthOfUuid = strlen($uuid);

$target = '0';
for($i=$lengthOfUuid-1;$i>=0;$i--)
{
    $a = to36encode($uuid{$i});
    $one = gmp_mul($a,gmp_pow(36,$i));
    $target = gmp_add($target,$one);
}

echo gmp_strval($target);
